import numpy as np
import tensorflow.compat.v2 as tf
tf.enable_v2_behavior()
import pandas as pd
from tensorflow import keras
from sklearn.preprocessing import StandardScaler
from sklearn.preprocessing import RobustScaler
from sklearn.preprocessing import MinMaxScaler
from matplotlib import pyplot
import plotly.graph_objects as go
import math
import seaborn as sns
from sklearn.metrics import mean_squared_error
np.random.seed(1)
tf.random.set_seed(1)
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, LSTM, GRU, Dropout, RepeatVector, TimeDistributed
from keras import backend
MODELFILENAME = 'MODELS/GRU_12h_TFM_2c'
TIME_STEPS=72 #12h
CMODEL = GRU
MODEL = "GRU"
UNITS=45
DROPOUT1=0.118
DROPOUT2=0.243
ACTIVATION='tanh'
OPTIMIZER='adamax'
EPOCHS=43
BATCHSIZE=30
VALIDATIONSPLIT=0.2
# Code to read csv file into Colaboratory:
# from google.colab import files
# uploaded = files.upload()
# import io
# df = pd.read_csv(io.BytesIO(uploaded['SentDATA.csv']))
# Dataset is now stored in a Pandas Dataframe
df = pd.read_csv('../../data/dadesTFM.csv')
df.reset_index(inplace=True)
df['Time'] = pd.to_datetime(df['Time'])
df = df.set_index('Time')
columns = ['PM1','PM25','PM10','PM1ATM','PM25ATM','PM10ATM']
df1 = df.copy();
df1 = df1.rename(columns={"PM 1":"PM1","PM 2.5":"PM25","PM 10":"PM10","PM 1 ATM":"PM1ATM","PM 2.5 ATM":"PM25ATM","PM 10 ATM":"PM10ATM"})
df1['PM1'] = df['PM 1'].astype(np.float32)
df1['PM25'] = df['PM 2.5'].astype(np.float32)
df1['PM10'] = df['PM 10'].astype(np.float32)
df1['PM1ATM'] = df['PM 1 ATM'].astype(np.float32)
df1['PM25ATM'] = df['PM 2.5 ATM'].astype(np.float32)
df1['PM10ATM'] = df['PM 10 ATM'].astype(np.float32)
df2 = df1.copy()
train_size = int(len(df2) * 0.8)
test_size = len(df2) - train_size
train, test = df2.iloc[0:train_size], df2.iloc[train_size:len(df2)]
train.shape, test.shape
((3117, 7), (780, 7))
#Standardize the data
for col in columns:
scaler = StandardScaler()
train[col] = scaler.fit_transform(train[[col]])
<ipython-input-6-83cecdbc25f8>:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy train[col] = scaler.fit_transform(train[[col]]) <ipython-input-6-83cecdbc25f8>:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy train[col] = scaler.fit_transform(train[[col]]) <ipython-input-6-83cecdbc25f8>:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy train[col] = scaler.fit_transform(train[[col]]) <ipython-input-6-83cecdbc25f8>:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy train[col] = scaler.fit_transform(train[[col]]) <ipython-input-6-83cecdbc25f8>:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy train[col] = scaler.fit_transform(train[[col]]) <ipython-input-6-83cecdbc25f8>:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy train[col] = scaler.fit_transform(train[[col]])
def create_sequences(X, y, time_steps=TIME_STEPS):
Xs, ys = [], []
for i in range(len(X)-time_steps):
Xs.append(X.iloc[i:(i+time_steps)].values)
ys.append(y.iloc[i+time_steps])
return np.array(Xs), np.array(ys)
X_train, y_train = create_sequences(train[[columns[1]]], train[columns[1]])
#X_test, y_test = create_sequences(test[[columns[1]]], test[columns[1]])
print(f'X_train shape: {X_train.shape}')
print(f'y_train shape: {y_train.shape}')
X_train shape: (3045, 72, 1) y_train shape: (3045,)
#afegir nova mètrica
def rmse(y_true, y_pred):
return backend.sqrt(backend.mean(backend.square(y_pred - y_true), axis=-1))
model = Sequential()
model.add(CMODEL(units = UNITS, return_sequences=True, input_shape=(X_train.shape[1], X_train.shape[2])))
model.add(Dropout(rate=DROPOUT1))
model.add(CMODEL(units = UNITS, return_sequences=True))
model.add(Dropout(rate=DROPOUT2))
model.add(TimeDistributed(Dense(1,kernel_initializer='normal',activation=ACTIVATION)))
model.compile(optimizer=OPTIMIZER, loss='mae',metrics=['mse',rmse])
model.summary()
Model: "sequential" _________________________________________________________________ Layer (type) Output Shape Param # ================================================================= gru (GRU) (None, 72, 45) 6480 _________________________________________________________________ dropout (Dropout) (None, 72, 45) 0 _________________________________________________________________ gru_1 (GRU) (None, 72, 45) 12420 _________________________________________________________________ dropout_1 (Dropout) (None, 72, 45) 0 _________________________________________________________________ time_distributed (TimeDistri (None, 72, 1) 46 ================================================================= Total params: 18,946 Trainable params: 18,946 Non-trainable params: 0 _________________________________________________________________
history = model.fit(X_train, y_train, epochs=EPOCHS, batch_size=BATCHSIZE, validation_split=VALIDATIONSPLIT,
callbacks=[keras.callbacks.EarlyStopping(monitor='val_loss', patience=5, mode='min')], shuffle=False)
Epoch 1/43 82/82 [==============================] - 5s 56ms/step - loss: 0.6864 - mse: 0.8325 - rmse: 0.7053 - val_loss: 0.3899 - val_mse: 0.3449 - val_rmse: 0.4305 Epoch 2/43 82/82 [==============================] - 4s 46ms/step - loss: 0.5804 - mse: 0.6397 - rmse: 0.6352 - val_loss: 0.3541 - val_mse: 0.3274 - val_rmse: 0.4028 Epoch 3/43 82/82 [==============================] - 4s 44ms/step - loss: 0.5779 - mse: 0.6353 - rmse: 0.6347 - val_loss: 0.3532 - val_mse: 0.3270 - val_rmse: 0.4014 Epoch 4/43 82/82 [==============================] - 4s 45ms/step - loss: 0.5757 - mse: 0.6325 - rmse: 0.6337 - val_loss: 0.3516 - val_mse: 0.3262 - val_rmse: 0.3995 Epoch 5/43 82/82 [==============================] - 3s 41ms/step - loss: 0.5742 - mse: 0.6305 - rmse: 0.6331 - val_loss: 0.3499 - val_mse: 0.3255 - val_rmse: 0.3977 Epoch 6/43 82/82 [==============================] - 4s 46ms/step - loss: 0.5726 - mse: 0.6287 - rmse: 0.6324 - val_loss: 0.3486 - val_mse: 0.3251 - val_rmse: 0.3964 Epoch 7/43 82/82 [==============================] - 4s 45ms/step - loss: 0.5712 - mse: 0.6276 - rmse: 0.6319 - val_loss: 0.3474 - val_mse: 0.3246 - val_rmse: 0.3951 Epoch 8/43 82/82 [==============================] - 3s 42ms/step - loss: 0.5704 - mse: 0.6266 - rmse: 0.6317 - val_loss: 0.3473 - val_mse: 0.3247 - val_rmse: 0.3947 Epoch 9/43 82/82 [==============================] - 3s 41ms/step - loss: 0.5695 - mse: 0.6258 - rmse: 0.6314 - val_loss: 0.3467 - val_mse: 0.3247 - val_rmse: 0.3942 Epoch 10/43 82/82 [==============================] - 3s 41ms/step - loss: 0.5687 - mse: 0.6251 - rmse: 0.6312 - val_loss: 0.3467 - val_mse: 0.3249 - val_rmse: 0.3941 Epoch 11/43 82/82 [==============================] - 4s 46ms/step - loss: 0.5681 - mse: 0.6245 - rmse: 0.6311 - val_loss: 0.3449 - val_mse: 0.3242 - val_rmse: 0.3924 Epoch 12/43 82/82 [==============================] - 3s 41ms/step - loss: 0.5676 - mse: 0.6242 - rmse: 0.6309 - val_loss: 0.3458 - val_mse: 0.3248 - val_rmse: 0.3930 Epoch 13/43 82/82 [==============================] - 3s 42ms/step - loss: 0.5670 - mse: 0.6236 - rmse: 0.6306 - val_loss: 0.3453 - val_mse: 0.3247 - val_rmse: 0.3925 Epoch 14/43 82/82 [==============================] - 3s 41ms/step - loss: 0.5666 - mse: 0.6233 - rmse: 0.6305 - val_loss: 0.3441 - val_mse: 0.3243 - val_rmse: 0.3914 Epoch 15/43 82/82 [==============================] - 4s 45ms/step - loss: 0.5664 - mse: 0.6232 - rmse: 0.6306 - val_loss: 0.3444 - val_mse: 0.3246 - val_rmse: 0.3916 Epoch 16/43 82/82 [==============================] - 3s 41ms/step - loss: 0.5659 - mse: 0.6226 - rmse: 0.6302 - val_loss: 0.3442 - val_mse: 0.3246 - val_rmse: 0.3913 Epoch 17/43 82/82 [==============================] - 3s 40ms/step - loss: 0.5656 - mse: 0.6224 - rmse: 0.6302 - val_loss: 0.3439 - val_mse: 0.3245 - val_rmse: 0.3910 Epoch 18/43 82/82 [==============================] - 4s 45ms/step - loss: 0.5653 - mse: 0.6222 - rmse: 0.6301 - val_loss: 0.3438 - val_mse: 0.3245 - val_rmse: 0.3908 Epoch 19/43 82/82 [==============================] - 4s 43ms/step - loss: 0.5650 - mse: 0.6219 - rmse: 0.6300 - val_loss: 0.3438 - val_mse: 0.3246 - val_rmse: 0.3907 Epoch 20/43 82/82 [==============================] - 3s 41ms/step - loss: 0.5648 - mse: 0.6217 - rmse: 0.6298 - val_loss: 0.3433 - val_mse: 0.3244 - val_rmse: 0.3902 Epoch 21/43 82/82 [==============================] - 4s 54ms/step - loss: 0.5648 - mse: 0.6217 - rmse: 0.6300 - val_loss: 0.3437 - val_mse: 0.3246 - val_rmse: 0.3905 Epoch 22/43 82/82 [==============================] - 4s 44ms/step - loss: 0.5642 - mse: 0.6208 - rmse: 0.6294 - val_loss: 0.3435 - val_mse: 0.3245 - val_rmse: 0.3901 Epoch 23/43 82/82 [==============================] - 4s 54ms/step - loss: 0.5640 - mse: 0.6206 - rmse: 0.6293 - val_loss: 0.3432 - val_mse: 0.3243 - val_rmse: 0.3897 Epoch 24/43 82/82 [==============================] - 5s 58ms/step - loss: 0.5638 - mse: 0.6205 - rmse: 0.6293 - val_loss: 0.3428 - val_mse: 0.3241 - val_rmse: 0.3892 Epoch 25/43 82/82 [==============================] - 5s 60ms/step - loss: 0.5634 - mse: 0.6202 - rmse: 0.6290 - val_loss: 0.3424 - val_mse: 0.3238 - val_rmse: 0.3887 Epoch 26/43 82/82 [==============================] - 3s 41ms/step - loss: 0.5633 - mse: 0.6200 - rmse: 0.6289 - val_loss: 0.3425 - val_mse: 0.3238 - val_rmse: 0.3887 Epoch 27/43 82/82 [==============================] - 4s 45ms/step - loss: 0.5630 - mse: 0.6196 - rmse: 0.6288 - val_loss: 0.3418 - val_mse: 0.3233 - val_rmse: 0.3879 Epoch 28/43 82/82 [==============================] - 3s 39ms/step - loss: 0.5628 - mse: 0.6195 - rmse: 0.6286 - val_loss: 0.3417 - val_mse: 0.3231 - val_rmse: 0.3877 Epoch 29/43 82/82 [==============================] - 3s 39ms/step - loss: 0.5626 - mse: 0.6190 - rmse: 0.6284 - val_loss: 0.3411 - val_mse: 0.3225 - val_rmse: 0.3868 Epoch 30/43 82/82 [==============================] - 3s 39ms/step - loss: 0.5622 - mse: 0.6186 - rmse: 0.6280 - val_loss: 0.3412 - val_mse: 0.3224 - val_rmse: 0.3867 Epoch 31/43 82/82 [==============================] - 3s 38ms/step - loss: 0.5620 - mse: 0.6183 - rmse: 0.6279 - val_loss: 0.3404 - val_mse: 0.3218 - val_rmse: 0.3858 Epoch 32/43 82/82 [==============================] - 3s 38ms/step - loss: 0.5618 - mse: 0.6181 - rmse: 0.6278 - val_loss: 0.3399 - val_mse: 0.3214 - val_rmse: 0.3853 Epoch 33/43 82/82 [==============================] - 3s 38ms/step - loss: 0.5615 - mse: 0.6177 - rmse: 0.6276 - val_loss: 0.3396 - val_mse: 0.3209 - val_rmse: 0.3847 Epoch 34/43 82/82 [==============================] - 3s 38ms/step - loss: 0.5613 - mse: 0.6174 - rmse: 0.6272 - val_loss: 0.3395 - val_mse: 0.3207 - val_rmse: 0.3845 Epoch 35/43 82/82 [==============================] - 4s 43ms/step - loss: 0.5612 - mse: 0.6171 - rmse: 0.6271 - val_loss: 0.3391 - val_mse: 0.3203 - val_rmse: 0.3841 Epoch 36/43 82/82 [==============================] - 4s 44ms/step - loss: 0.5608 - mse: 0.6166 - rmse: 0.6269 - val_loss: 0.3383 - val_mse: 0.3198 - val_rmse: 0.3832 Epoch 37/43 82/82 [==============================] - 4s 46ms/step - loss: 0.5607 - mse: 0.6167 - rmse: 0.6269 - val_loss: 0.3381 - val_mse: 0.3195 - val_rmse: 0.3830 Epoch 38/43 82/82 [==============================] - 4s 44ms/step - loss: 0.5605 - mse: 0.6163 - rmse: 0.6268 - val_loss: 0.3376 - val_mse: 0.3192 - val_rmse: 0.3824 Epoch 39/43 82/82 [==============================] - 4s 43ms/step - loss: 0.5603 - mse: 0.6162 - rmse: 0.6269 - val_loss: 0.3370 - val_mse: 0.3190 - val_rmse: 0.3820 Epoch 40/43 82/82 [==============================] - 3s 41ms/step - loss: 0.5601 - mse: 0.6159 - rmse: 0.6268 - val_loss: 0.3372 - val_mse: 0.3191 - val_rmse: 0.3822 Epoch 41/43 82/82 [==============================] - 4s 43ms/step - loss: 0.5602 - mse: 0.6160 - rmse: 0.6269 - val_loss: 0.3365 - val_mse: 0.3187 - val_rmse: 0.3815 Epoch 42/43 82/82 [==============================] - 4s 52ms/step - loss: 0.5600 - mse: 0.6158 - rmse: 0.6269 - val_loss: 0.3367 - val_mse: 0.3188 - val_rmse: 0.3817 Epoch 43/43 82/82 [==============================] - 5s 56ms/step - loss: 0.5597 - mse: 0.6155 - rmse: 0.6267 - val_loss: 0.3359 - val_mse: 0.3182 - val_rmse: 0.3808
import matplotlib.pyplot as plt
plt.plot(history.history['loss'], label='MAE Training loss')
plt.plot(history.history['val_loss'], label='MAE Validation loss')
plt.plot(history.history['mse'], label='MSE Training loss')
plt.plot(history.history['val_mse'], label='MSE Validation loss')
plt.plot(history.history['rmse'], label='RMSE Training loss')
plt.plot(history.history['val_rmse'], label='RMSE Validation loss')
plt.legend();
X_train_pred = model.predict(X_train, verbose=0)
train_mae_loss = np.mean(np.abs(X_train_pred - X_train), axis=1)
plt.hist(train_mae_loss, bins=50)
plt.xlabel('Train MAE loss')
plt.ylabel('Number of Samples');
def evaluate_prediction(predictions, actual, model_name):
errors = predictions - actual
mse = np.square(errors).mean()
rmse = np.sqrt(mse)
mae = np.abs(errors).mean()
print(model_name + ':')
print('Mean Absolute Error: {:.4f}'.format(mae))
print('Root Mean Square Error: {:.4f}'.format(rmse))
print('Mean Square Error: {:.4f}'.format(mse))
print('')
return mae,rmse,mse
mae,rmse,mse = evaluate_prediction(X_train_pred, X_train,MODEL)
GRU: Mean Absolute Error: 0.2251 Root Mean Square Error: 0.4538 Mean Square Error: 0.2060
model.save(MODELFILENAME+'.h5')
#càlcul del threshold de test
def calculate_threshold(X_test, X_test_pred):
distance = np.sqrt(np.mean(np.square(X_test_pred - X_test),axis=1))
"""Sorting the scores/diffs and using a 0.80 as cutoff value to pick the threshold"""
distance.sort();
cut_off = int(0.9 * len(distance));
threshold = distance[cut_off];
return threshold
for col in columns:
print ("####################### "+col +" ###########################")
#Standardize the test data
scaler = StandardScaler()
test_cpy = test.copy()
test[col] = scaler.fit_transform(test[[col]])
#creem seqüencia amb finestra temporal per les dades de test
X_test1, y_test1 = create_sequences(test[[col]], test[col])
print(f'Testing shape: {X_test1.shape}')
#evaluem el model
eval = model.evaluate(X_test1, y_test1)
print("evaluate: ",eval)
#predim el model
X_test1_pred = model.predict(X_test1, verbose=0)
evaluate_prediction(X_test1_pred, X_test1,MODEL)
#càlcul del mae_loss
test1_mae_loss = np.mean(np.abs(X_test1_pred - X_test1), axis=1)
test1_rmse_loss = np.sqrt(np.mean(np.square(X_test1_pred - X_test1),axis=1))
# reshaping test prediction
X_test1_predReshape = X_test1_pred.reshape((X_test1_pred.shape[0] * X_test1_pred.shape[1]), X_test1_pred.shape[2])
# reshaping test data
X_test1Reshape = X_test1.reshape((X_test1.shape[0] * X_test1.shape[1]), X_test1.shape[2])
threshold_test = calculate_threshold(X_test1Reshape,X_test1_predReshape)
test1_score_df = pd.DataFrame(test[TIME_STEPS:])
test1_score_df['loss'] = test1_rmse_loss.reshape((-1))
test1_score_df['threshold'] = threshold_test
test1_score_df['anomaly'] = test1_score_df['loss'] > test1_score_df['threshold']
test1_score_df[col] = test[TIME_STEPS:][col]
#gràfic test lost i threshold
fig = go.Figure()
fig.add_trace(go.Scatter(x=test1_score_df.index, y=test1_score_df['loss'], name='Test loss'))
fig.add_trace(go.Scatter(x=test1_score_df.index, y=test1_score_df['threshold'], name='Threshold'))
fig.update_layout(showlegend=True, title='Test loss vs. Threshold')
fig.show()
#Posem les anomalies en un array
anomalies1 = test1_score_df.loc[test1_score_df['anomaly'] == True]
anomalies1.shape
print('anomalies: ',anomalies1.shape); print();
#Gràfic dels punts i de les anomalíes amb els valors de dades transformades per verificar que la normalització que s'ha fet no distorssiona les dades
fig = go.Figure()
fig.add_trace(go.Scatter(x=test1_score_df.index, y=scaler.inverse_transform(test1_score_df[col]), name=col))
fig.add_trace(go.Scatter(x=anomalies1.index, y=scaler.inverse_transform(anomalies1[col]), mode='markers', name='Anomaly'))
fig.update_layout(showlegend=True, title='Detected anomalies')
fig.show()
print ("######################################################")
####################### PM1 ########################### Testing shape: (708, 72, 1) 1/23 [>.............................] - ETA: 0s - loss: 0.2370 - mse: 0.2052 - rmse: 0.4512
<ipython-input-17-e1f1d6df3b5c>:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy test[col] = scaler.fit_transform(test[[col]])
23/23 [==============================] - 0s 12ms/step - loss: 0.5970 - mse: 0.8793 - rmse: 0.7017 evaluate: [0.5970004796981812, 0.8793271780014038, 0.7016565799713135] GRU: Mean Absolute Error: 0.1749 Root Mean Square Error: 0.5153 Mean Square Error: 0.2656
anomalies: (340, 10)
###################################################### ####################### PM25 ########################### Testing shape: (708, 72, 1) 1/23 [>.............................] - ETA: 0s - loss: 0.2383 - mse: 0.1922 - rmse: 0.4352
<ipython-input-17-e1f1d6df3b5c>:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
23/23 [==============================] - 0s 10ms/step - loss: 0.6273 - mse: 0.9459 - rmse: 0.7320 evaluate: [0.6273448467254639, 0.945933997631073, 0.7320307493209839] GRU: Mean Absolute Error: 0.1890 Root Mean Square Error: 0.4809 Mean Square Error: 0.2313
anomalies: (286, 10)
###################################################### ####################### PM10 ########################### Testing shape: (708, 72, 1)
<ipython-input-17-e1f1d6df3b5c>:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
23/23 [==============================] - 0s 11ms/step - loss: 0.6472 - mse: 0.9911 - rmse: 0.7526 evaluate: [0.6472277045249939, 0.991119921207428, 0.7525621652603149] GRU: Mean Absolute Error: 0.1989 Root Mean Square Error: 0.4490 Mean Square Error: 0.2016
anomalies: (200, 10)
###################################################### ####################### PM1ATM ########################### Testing shape: (708, 72, 1)
<ipython-input-17-e1f1d6df3b5c>:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
23/23 [==============================] - 0s 11ms/step - loss: 0.6477 - mse: 0.9159 - rmse: 0.7585 evaluate: [0.6476801037788391, 0.9159324169158936, 0.7585272789001465] GRU: Mean Absolute Error: 0.1972 Root Mean Square Error: 0.4537 Mean Square Error: 0.2059
anomalies: (157, 10)
###################################################### ####################### PM25ATM ########################### Testing shape: (708, 72, 1)
<ipython-input-17-e1f1d6df3b5c>:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
23/23 [==============================] - 0s 10ms/step - loss: 0.6415 - mse: 0.9006 - rmse: 0.7512 evaluate: [0.641465425491333, 0.900642454624176, 0.7512214183807373] GRU: Mean Absolute Error: 0.1945 Root Mean Square Error: 0.4613 Mean Square Error: 0.2128
anomalies: (158, 10)
###################################################### ####################### PM10ATM ########################### Testing shape: (708, 72, 1) 1/23 [>.............................] - ETA: 0s - loss: 0.2354 - mse: 0.1801 - rmse: 0.4217
<ipython-input-17-e1f1d6df3b5c>:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
23/23 [==============================] - 0s 12ms/step - loss: 0.6358 - mse: 0.8980 - rmse: 0.7405 evaluate: [0.6357605457305908, 0.8979535102844238, 0.7405362129211426] GRU: Mean Absolute Error: 0.1963 Root Mean Square Error: 0.4657 Mean Square Error: 0.2169
anomalies: (157, 10)
######################################################